package map;

import java.util.HashSet;

public class L242 {
    public boolean isAnagram(String s, String t) {
       /* char[] record = new char[26];
        for (int i=0;i<s.length();i++){
            char c = s.charAt(i);
            int index=c-'a';
            record[index]+=1;
        }
        for (int i=0;i<t.length();i++){
            char c = t.charAt(i);
            int index=c-'a';
            record[index]-=1;
        }
        for (Character c:record){
            if (c !=0){
                return false;
            }
        }
        return true;*/

        //下面这个是暴力解法
        char[] chars = s.toCharArray();
        char[] chart = t.toCharArray();
        for (int i=0;i<chars.length;i++){
            boolean found=false;
            for (int j=0;j<chart.length;j++){
                if (chart[j]==chars[i]){
                    chars[j]='\0';
                    found=true;
                    break;
                }
            }
            if (!found){
                return false;
            }

        }
        return true;


    }


}
